Skip to content

fix(Intl): make Intl.Collator.compare a getter that returns a bound function (#62048)#62052

Open
ahsansheikh94 wants to merge 2 commits intomicrosoft:mainfrom
ahsansheikh94:fix-intl-collator-compare-type
Open

fix(Intl): make Intl.Collator.compare a getter that returns a bound function (#62048)#62052
ahsansheikh94 wants to merge 2 commits intomicrosoft:mainfrom
ahsansheikh94:fix-intl-collator-compare-type

Conversation

@ahsansheikh94
Copy link

@ahsansheikh94 ahsansheikh94 commented Jul 12, 2025

What this PR does

This PR updates the type definition for Intl.Collator.prototype.compare to align with the ECMAScript specification.

Previously, compare was declared as a method:
compare(x: string, y: string): number;

According to the spec, it is a getter that returns a bound function:
get compare(): (this: void, x: string, y: string) => number;

Changing this to a getter would cause conflicts with the existing implementations as pointed out by @Renegade334.
Instead adding a this: void gets the job done.

Changes made

  • Updated the Intl.Collator interface in src/lib/es5.d.ts:
  • Added a new conformance test in tests/cases/conformance/intl/collatorCompareBoundFunction.ts

Related Issue

Fixes #62048

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 12, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jul 12, 2025
@ahsansheikh94
Copy link
Author

@microsoft-github-policy-service agree

Comment on lines +1 to +2
// @target: es2022
// @lib: es2022.intl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es2022.intl doesn't reference lib.es5, so Collator isn't actually defined in your test script (check the baselines).

Either change this to

Suggested change
// @target: es2022
// @lib: es2022.intl
// @target: es5
// @lib: es5

or just get rid of the lib option entirely, and use the default.

@DanielRosenwasser
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 7, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser Here are the results of running the user tests with tsc comparing main and refs/pull/62052/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 82,521 82,522 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 125,280 125,280 ~ ~ ~ p=1.000 n=6
Memory used 277,802k (± 0.04%) 277,692k (± 0.06%) ~ 277,468k 277,909k p=0.298 n=6
Parse Time 1.59s (± 1.80%) 1.59s (± 2.51%) ~ 1.54s 1.64s p=0.936 n=6
Bind Time 0.91s (± 0.83%) 0.93s (± 1.47%) +0.02s (+ 2.02%) 0.90s 0.94s p=0.039 n=6
Check Time 17.53s (± 1.97%) 17.61s (± 2.08%) ~ 16.93s 18.01s p=1.000 n=6
Emit Time 3.29s (± 5.36%) 3.31s (± 5.26%) ~ 3.21s 3.66s p=0.470 n=6
Total Time 23.33s (± 1.23%) 23.44s (± 2.04%) ~ 22.68s 24.15s p=0.810 n=6
angular-1 - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 957,229 957,230 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 416,021 416,021 ~ ~ ~ p=1.000 n=6
Memory used 1,257,842k (± 0.01%) 1,257,829k (± 0.01%) ~ 1,257,724k 1,257,965k p=0.810 n=6
Parse Time 7.98s (± 0.98%) 7.99s (± 0.70%) ~ 7.94s 8.08s p=0.936 n=6
Bind Time 2.39s (± 0.22%) 2.40s (± 0.44%) ~ 2.38s 2.41s p=0.142 n=6
Check Time 38.85s (± 0.25%) 38.82s (± 0.38%) ~ 38.61s 39.06s p=0.468 n=6
Emit Time 17.98s (± 0.27%) 17.97s (± 0.45%) ~ 17.85s 18.07s p=0.810 n=6
Total Time 67.19s (± 0.11%) 67.18s (± 0.23%) ~ 66.99s 67.42s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Errors 11,439 11,439 ~ ~ ~ p=1.000 n=6
Symbols 2,702,777 2,702,778 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 930,727 930,727 ~ ~ ~ p=1.000 n=6
Memory used 3,040,186k (± 0.00%) 3,040,240k (± 0.01%) ~ 3,039,855k 3,040,553k p=0.575 n=6
Parse Time 10.37s (± 0.34%) 10.34s (± 0.27%) ~ 10.30s 10.37s p=0.126 n=6
Bind Time 2.78s (± 0.37%) 2.79s (± 0.75%) ~ 2.75s 2.81s p=0.114 n=6
Check Time 112.75s (± 2.13%) 111.70s (± 0.94%) ~ 110.60s 113.54s p=0.471 n=6
Emit Time 0.39s (± 3.24%) 0.75s (±121.54%) ~ 0.37s 2.63s p=0.549 n=6
Total Time 126.28s (± 1.94%) 125.58s (± 1.01%) ~ 124.15s 127.11s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,253,400 1,253,413 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Types 260,196 260,196 ~ ~ ~ p=1.000 n=6
Memory used 2,643,835k (±14.26%) 3,033,870k (± 7.77%) ~ 2,551,890k 3,131,037k p=0.230 n=6
Parse Time 6.59s (± 2.11%) 6.65s (± 1.04%) ~ 6.51s 6.69s p=0.575 n=6
Bind Time 2.27s (± 1.92%) 2.24s (± 1.39%) ~ 2.21s 2.29s p=0.470 n=6
Check Time 43.03s (± 0.64%) 42.99s (± 0.62%) ~ 42.51s 43.22s p=0.810 n=6
Emit Time 3.48s (± 2.40%) 3.54s (± 2.27%) ~ 3.43s 3.66s p=0.261 n=6
Total Time 55.36s (± 0.58%) 55.42s (± 0.57%) ~ 54.85s 55.74s p=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,253,400 1,253,413 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Types 260,196 260,196 ~ ~ ~ p=1.000 n=6
Memory used 3,195,171k (± 0.03%) 3,073,026k (± 9.65%) 🟩-122,144k (- 3.82%) 2,467,159k 3,195,420k p=0.045 n=6
Parse Time 8.42s (± 0.62%) 8.43s (± 0.80%) ~ 8.30s 8.48s p=0.423 n=6
Bind Time 2.74s (± 0.72%) 2.75s (± 1.41%) ~ 2.72s 2.81s p=0.936 n=6
Check Time 53.49s (± 0.46%) 53.57s (± 0.34%) ~ 53.40s 53.86s p=0.378 n=6
Emit Time 4.35s (± 2.02%) 4.40s (± 2.53%) ~ 4.25s 4.57s p=0.471 n=6
Total Time 69.03s (± 0.37%) 69.16s (± 0.35%) ~ 68.86s 69.52s p=0.298 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,166 265,167 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 104,270 104,270 ~ ~ ~ p=1.000 n=6
Memory used 444,318k (± 0.01%) 444,310k (± 0.01%) ~ 444,279k 444,345k p=0.810 n=6
Parse Time 2.87s (± 0.41%) 2.89s (± 0.72%) ~ 2.86s 2.92s p=0.142 n=6
Bind Time 1.16s (± 0.71%) 1.16s (± 0.72%) ~ 1.14s 1.16s p=1.000 n=6
Check Time 16.05s (± 0.48%) 16.04s (± 0.34%) ~ 15.96s 16.10s p=0.936 n=6
Emit Time 1.32s (± 0.39%) 1.33s (± 1.14%) ~ 1.31s 1.35s p=1.000 n=6
Total Time 21.40s (± 0.32%) 21.40s (± 0.35%) ~ 21.32s 21.51s p=1.000 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 271 271 ~ ~ ~ p=1.000 n=6
Symbols 225,135 225,136 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 93,554 93,554 ~ ~ ~ p=1.000 n=6
Memory used 370,570k (± 0.02%) 370,556k (± 0.02%) ~ 370,461k 370,633k p=0.936 n=6
Parse Time 2.83s (± 1.14%) 2.86s (± 0.65%) ~ 2.83s 2.88s p=0.196 n=6
Bind Time 1.63s (± 1.81%) 1.63s (± 0.98%) ~ 1.61s 1.65s p=0.871 n=6
Check Time 17.39s (± 0.30%) 17.36s (± 0.52%) ~ 17.26s 17.49s p=0.471 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 21.84s (± 0.28%) 21.85s (± 0.46%) ~ 21.70s 21.97s p=1.000 n=6
vscode - node (v18.15.0, x64)
Errors 40 40 ~ ~ ~ p=1.000 n=6
Symbols 4,231,542 4,231,543 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,343,719 1,343,719 ~ ~ ~ p=1.000 n=6
Memory used 4,024,860k (± 0.00%) 4,024,846k (± 0.00%) ~ 4,024,757k 4,025,025k p=0.748 n=6
Parse Time 16.30s (± 0.18%) 16.36s (± 0.32%) ~ 16.31s 16.44s p=0.053 n=6
Bind Time 5.51s (± 0.50%) 5.47s (± 0.67%) ~ 5.44s 5.54s p=0.053 n=6
Check Time 124.19s (± 2.26%) 124.42s (± 1.52%) ~ 122.11s 126.63s p=0.936 n=6
Emit Time 50.89s (±16.97%) 53.42s (±14.42%) ~ 44.58s 64.25s p=0.689 n=6
Total Time 196.89s (± 5.34%) 199.67s (± 4.23%) ~ 189.14s 212.77s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 41 41 ~ ~ ~ p=1.000 n=6
Symbols 403,241 403,242 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 178,738 178,738 ~ ~ ~ p=1.000 n=6
Memory used 560,985k (± 0.02%) 561,079k (± 0.05%) ~ 560,873k 561,626k p=0.936 n=6
Parse Time 5.93s (± 0.44%) 5.94s (± 0.41%) ~ 5.91s 5.97s p=0.222 n=6
Bind Time 2.51s (± 1.51%) 2.50s (± 0.70%) ~ 2.47s 2.52s p=0.567 n=6
Check Time 30.25s (± 0.15%) 30.33s (± 0.68%) ~ 29.95s 30.53s p=0.127 n=6
Emit Time 0.01s (±109.43%) 0.00s (±154.76%) ~ 0.00s 0.01s p=0.640 n=6
Total Time 38.69s (± 0.18%) 38.77s (± 0.57%) ~ 38.36s 38.99s p=0.127 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 752,846 752,847 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 215,171 215,171 ~ ~ ~ p=1.000 n=6
Memory used 676,996k (± 0.01%) 677,025k (± 0.01%) ~ 676,978k 677,064k p=0.173 n=6
Parse Time 4.89s (± 0.28%) 4.88s (± 0.84%) ~ 4.81s 4.92s p=0.935 n=6
Bind Time 1.57s (± 0.33%) 1.57s (± 0.67%) ~ 1.55s 1.58s p=0.794 n=6
Check Time 22.29s (± 0.35%) 22.31s (± 0.51%) ~ 22.11s 22.42s p=0.575 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.75s (± 0.28%) 28.76s (± 0.54%) ~ 28.49s 28.92s p=0.689 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62052/merge:

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Intl.Collator#compare method type does not match spec

4 participants